import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.concurrent.locks.ReentrantLock;

public class Thread56 {
    public static void main(String[] args) {
        byte a=-1;
    }
    public static void main1(String[] args) {
       // int count=0;
        Callable<Integer>a=new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                int count=0;
                for(int i=0;i<100;i++)
                {
                    count++;
                }
                return count;

            }
        };
        FutureTask<Integer>futureTask=new FutureTask<>(a);
        Thread t1=new Thread(futureTask);
        t1.start();
        try {
            t1.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        try {
            Integer result=futureTask.get();//获取结果
            System.out.println(result);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } catch (ExecutionException e) {
            throw new RuntimeException(e);
        }

    }
}
